<#import "/spring.ftl" as spring />
<#import "/inspector-time-macros.ftl" as imacro />
<#setting number_format="0.##"/>

<html>
<head>
	<title>inspection</title>
</head>
<body>

<script src="${springMacroRequestContext.contextPath}/js/it-common.js" type="text/javascript"></script>
<script src="${springMacroRequestContext.contextPath}/js/prototype.js" type="text/javascript"></script>
<script src="${springMacroRequestContext.contextPath}/js/scriptaculous/scriptaculous.js" type="text/javascript"></script>

<script>
//Builds out the list of realtors for the autocomplete textfield
var realtorsList = [
  <#list referringRealtors as realtor>
    '${realtor.name.last}, ${realtor.name.first}<#if realtor.company??> - ${realtor.company!}</#if>'<#if realtor_has_next>,</#if>
  </#list>
];
</script>

<script>
	/**
	 * Toggles the visibility of the "Enter Agent Fields" div
	 */
	function toggleAgentFields(checkbox) {
		if (checkbox.checked) {
			show('enterAgentFields');
		} else {
			hide('enterAgentFields');
		}
	}
</script>

<#include "../inspectionDropDownValues.ftl" />

<#-- Provides a consistent format for the "Scheduled Inspection" dropdown displayed options (as well as the non-javascript enabled version) -->
<#macro dropdownValueFormatter date time id>${date?string("MMM dd, yyyy")} ${time?string("hh:mm:ss a")}|${id}</#macro>

<#-- Provides a consistent format for the "Scheduled Inspection" dropdown values (as well as the non-javascript enabled version). 
	 If you change this, be sure to change the respective Controller class -->
<#macro dropdownDisplayFormatter date time>${date?string("EEEE, MMM dd")} at ${time?string("hh:mm:ss a")}</#macro>

<script language="javascript">

	//for when editing an existing inspection, or returning to the form from a validation error
	var existingInspectionInspectorId = "";
	var inspectorArray = new Array();
	
	<#-- Loops thru the freemarker inspector objects to build out 
		an array of javascript inspectors -->
	<#list inspectors as inspector>
		<#assign ind = -1 />
		<#assign days = inspectorDays[inspector.id] />
		
		var displayTimes = new Array();
		var optionValueTimes = new Array();
		
		<#list days as day>
			<#if (day.hasAvailableTimeslot()) >
				<#list day.timeslots as timeslot>
					<#if timeslot.available>
						<#assign ind = ind+1 >
						displayTimes[${ind}] = '<@dropdownDisplayFormatter day.toDate() timeslot.startTime.toDate() />';
						optionValueTimes[${ind}] = '<@dropdownValueFormatter day.toDate() timeslot.startTime.toDate() inspector.id />';
					</#if>
				</#list>
			</#if>
		</#list>
		inspectorArray[${inspector_index}] = new Inspector('${inspector.id}', '${inspector.name}', displayTimes, optionValueTimes);
	</#list>
	
	<#-- If we are editing an Inspection, define javascript variables so we can prepopulate the dropdowns -->
	<#if criteria.inspection??>
		existingInspectionInspectorId = '${(criteria.inspection.inspector.id)!}';
		var existingInspectionDisplayTime;
		var existingInspectionOptionValueTime;
		<#if criteria.inspection.inspectionTime??>
	 		existingInspectionDisplayTime = '<@dropdownDisplayFormatter criteria.inspection.inspectionTime criteria.inspection.inspectionTime />';
			existingInspectionOptionValueTime = '<@dropdownValueFormatter criteria.inspection.inspectionTime criteria.inspection.inspectionTime criteria.inspection.inspector.id />';
		</#if>
	</#if>

	//Creates a javascript inspector object for use when building out the dropdown options
	function Inspector(id, name, displayTimes, optionValueTimes) {
		this.id = id;
		this.name = name;
		this.displayTimes = displayTimes;
		this.optionValueTimes = optionValueTimes;
	}

	//Create a dropdown option and adds it to a selectbox
	function addOption(selectbox, text, value ) {
		var optn = document.createElement("OPTION");
		optn.text = text;
		optn.value = value;
		selectbox.options.add(optn);
	}

	//Populate the timeslots dropdown with availibility options specific to the inspector
	//identified by selectedId
	function populate(selectedId) {
	 	var slotsDropDown = document.getElementById('timeslotsDropDown');
	 	clean(slotsDropDown);
	 	var inspector = null;
	 	
	 	for (i = 0; i < inspectorArray.length; i++) {
	 		if (inspectorArray[i].id == selectedId) {
	 			inspector = inspectorArray[i];
	 		}
	 	}
	 	
	 	//If it exists, add the originally selected time as the first option
	 	if (existingInspectionInspectorId != "" && selectedId == existingInspectionInspectorId) {
	 		addOption(slotsDropDown, existingInspectionDisplayTime, existingInspectionOptionValueTime);
	 	}
	 	addOption(slotsDropDown, "Select Time for " + inspector.name, "UNASSIGNED");
		for (i = 0; i < inspector.displayTimes.length; i++) {
			addOption(slotsDropDown, inspector.displayTimes[i], inspector.optionValueTimes[i]);
		}
	}
	
	//Removes all options from a select box
	function clean(selectbox) {
	 	 for (i = selectbox.length - 1; i>=0; i--) {
	 		selectbox.remove(i);
	 	}
	}
	
	//Set "selected" the inspector in the dropdown list identified by id
	function setSelectedInspector(selectbox, id) {
		for (i = 0; i < selectbox.length; i++) {
			if (selectbox.options[i].value == id) {
				selectbox.options[i].selected = true;
			}
		}
	}
	
	//Sets up the Inspector/Inspection dropdowns on load
	function setUp() {
		var selectedId;
		var inspectorsDropDown = document.getElementById('inspectorsDropDown');
		
		if (existingInspectionInspectorId != "") {
			selectedId = existingInspectionInspectorId;
			setSelectedInspector(inspectorsDropDown, selectedId);
		} else {
			selectedId = inspectorsDropDown.options[0].value;		
		}
		populate(selectedId);
	}


	/**
	 * Cleans up any values prior to passing them to server to be persisted
	 */
	function formatFieldValues() {
		//clean the entered fee
		feeField = document.getElementById('inspection.enteredInspectionFee');
		feeField.value = cleanCurrency(feeField.value);	  
	
		//clean the listed price field
	    priceField = document.getElementById('inspection.property.listedPrice');
		priceField.value = cleanCurrency(priceField.value);	  
	}
	

	window.onload = setUp;
	
</script>


<div id="content">

	<h1>INSPECTION DETAILS</h1>

	<@imacro.listErrors "criteria" />

	<form action="editInspection.html" method="post" onsubmit="formatFieldValues()">
	
	<#if criteria.inspection.id??>
		<input type="hidden" name="id" value="${criteria.inspection.id}" />
	</#if>

	<div class="databoxWrapper">
		<div class="databox">
			<h1>PRICE AND TIME</h1>
			<table class="databoxLabelTable2Cols">
			<tr>
				<th>INSPECTOR</th>
				<td class="middle">
					<select name="inspectors" onchange="populate(this.options[selectedIndex].value)" id="inspectorsDropDown">
						<#list inspectors as inspector>
							<option value="${inspector.id}">${inspector.name}</option>
						</#list>
					</select>
				</td>
			</tr>
			<tr>
				<th>SCHEDULED INSPECTION *</th>
				<td class="middle">
					<select name="manualBindingDateTimeInspector" id="timeslotsDropDown">
	 				</select>
	 			</td>
			</tr>
			<tr>
				<#if criteria.inspection.id??>
					<th>CALCULATED INSPECTION FEE</th>
					<td>$${criteria.inspection.inspectionFee}</td>
				</#if>
			</tr>
			<tr>				
				<th>ENTERED INSPECTION FEE<br/>(including additional services)</th>
				<td>
					<@spring.bind "criteria.inspection.enteredInspectionFee" />
					<#if criteria.inspection.enteredInspectionFee == 0>							
						<input type="text" name="${spring.status.expression}" 
							value="" size="10" maxlength="13"/>
					<#else>
						<input type="text" name="${spring.status.expression}" 
							value="${spring.status.value?default("")}"  size="10" maxlength="13"/>							
					</#if>
				</td>
			</tr>
			
			<#-- Only display inspection status if user is editing. -->
			<#if criteria.inspection.id??>
				<tr>
					<th>INSPECTION STATUS</th>
					<td>
						<@imacro.enumDropDown "criteria.inspection.inspectionStatus", inspectionStatuses />
					</td>
				</tr>
			</#if>

			<tr>
				<th>PAYMENT STATUS</th>
				<td>
					<@imacro.enumDropDown "criteria.inspection.paymentStatus", paymentStatuses />
				</td>
			</tr>
			
			</table>
		</div>
	</div>
	
	<#-- The following is in support of Blackberrys, etc.  If we don't need it, let's get rid of it! -->
	<noscript>
	<div class="databoxWrapper">
		<div class="databox">
		
			<h1>SELECT INSPECTOR AND TIME</h1>
			
			<p>We've determined that you are using a non-javascript enabled browser.  Please ignore the "Scheduled Inspection" dropdown 
			   above and select your inspector/timeslot from the dropdown below.</p>
			
			<p>
				<!-- Timeslot selection slots -->
				<select name="manualBindingDateTimeInspector" style="width:50%">
								
				<!-- Show selected slot first -->
				<#if criteria.inspection.id??>
					<option value="<@dropdownValueFormatter criteria.inspection.inspectionTime criteria.inspection.inspectionTime criteria.inspection.inspector.id />" >
						<@dropdownDisplayFormatter criteria.inspection.inspectionTime criteria.inspection.inspectionTime /> ${criteria.inspection.inspector.name.first?upper_case} ${criteria.inspection.inspector.name.last?upper_case}
					</option>
				<#else>
					<option value="UNASSIGNED">-- SELECT TIMESLOT AND INSPECTOR --</option>
				</#if>
								
				<#assign rangeDays = inspectorDays?values[0] />
				<#list 0..(rangeDays?size -1) as dayCounter>
					<#assign day = rangeDays[dayCounter].toDate() />
					<#assign timeslotDisplayed = false />
									
					<#-- loop thru each inspector and see if there's a timeslot(s) in this day -->
					<#list inspectors as inspector>
										
						<#assign inspectorDaysList = inspectorDays[inspector.id] />
						<#assign thisDay = inspectorDaysList[dayCounter] />
					
						<#if (thisDay.hasAvailableTimeslot()) >
							<#assign inspectorNameFirst = inspector.name.first?upper_case />
							<#assign inspectorNameLast = inspector.name.last?upper_case />
							<#list thisDay.timeslots as timeslot>
								<#if timeslot.available>
									<option value="<@dropdownValueFormatter day timeslot.startTime.toDate() inspector.id />" >
										<@dropdownDisplayFormatter day timeslot.startTime.toDate() /> ${inspectorNameFirst} ${inspectorNameLast}
									</option>	
								</#if>
							</#list>
						</#if>
					</#list> <#-- end inspectors loop -->
				</#list>
				</select>
			</p>
		</div>
	</div>
	</noscript>
	
	<div class="databoxWrapper">
		<div class="databox">
			<h1>CUSTOMER INFORMATION</h1>
			<table class="databoxLabelTable4Cols">
			<tr>
				<th>FIRST NAME*</th>
				<td class="middle"><@spring.formInput "criteria.inspection.homeBuyer.name.first", 'size="30", maxlength="50"'/></td>
				<th>LAST NAME*</th>
				<td><@spring.formInput "criteria.inspection.homeBuyer.name.last", 'size="30", maxlength="50"' /></td>
			</tr>
			<tr>
				<th>EMAIL*</th>
				<td class="middle"><@spring.formInput "criteria.inspection.homeBuyer.email", 'size="30", maxlength="100"' /></td>
				<th>CONTACT TELEPHONE*</th>
				<td><@spring.formInput "criteria.inspection.homeBuyer.phone", 'size="30", maxlength="20"' /></td>
			</tr>
			<tr>
				<th>ADDITIONAL TELEPHONE</th>
				<td class="middle"><@spring.formInput "criteria.inspection.homeBuyer.secondaryPhone", 'size="30", maxlength="20"' /></td>
				<th>FAX</th>
				<td class="middle"><@spring.formInput "criteria.inspection.homeBuyer.fax", 'size="30", maxlength="20"' /></td>
			</tr>
			<tr>
				<th>HOME ADDRESS</th>
				<td class="middle"><@spring.formInput "criteria.inspection.homeBuyer.address.street1", 'size="30", maxlength="100"' /></td>
				<th>CITY</th>
				<td><@spring.formInput "criteria.inspection.homeBuyer.address.city", 'size="30", maxlength="100"' /></td>
			</tr>
			<tr>
				<th>STATE</th>
				<td class="middle">
					<@spring.bind "criteria.inspection.homeBuyer.address.state" />
					<select id="${spring.status.expression}" name="${spring.status.expression}">
						<option value=""<@spring.checkSelected ""/>>-- SELECT STATE --</option>
					    <#list allStates as option>
				    		<option value="${option}"<@spring.checkSelected option/>>${option.longName}</option>
				        </#list>
					</select>	
				</td>
				<th>ZIP</th>
				<td><@spring.formInput "criteria.inspection.homeBuyer.address.zipCode", 'size="10", maxlength="5"' /></td>
			</tr>
			</table>
		</div>
	</div>	

	<div class="databoxWrapper">
		<div class="databox">
			<h1>SECOND CUSTOMER INFORMATION</h1>
			<table class="databoxLabelTable4Cols">
			<tr>
				<th>FIRST NAME</th>
				<td class="middle"><@spring.formInput "criteria.secondHomeBuyer.name.first", 'size="30", maxlength="50"' /></td>
				<th>LAST NAME</th>
				<td><@spring.formInput "criteria.secondHomeBuyer.name.last", 'size="30", maxlength="50"' /></td>
			</tr>
			<tr>
				<th>EMAIL</th>
				<td class="middle"><@spring.formInput "criteria.secondHomeBuyer.email", 'size="30", maxlength="100"' /></td>
				<th>CONTACT TELEPHONE</th>
				<td><@spring.formInput "criteria.secondHomeBuyer.phone", 'size="30", maxlength="20"' /></td>
			</tr>
			</table>
		</div>
	</div>	
	
	<div class="databoxWrapper">
		<div class="databox">
			<h1>PHYSICAL PROPERTY INFORMATION</h1>
			<table class="databoxLabelTable4Cols">
			<tr>
				<th>ADDRESS*</th>
				<td class="middle"><@spring.formInput "criteria.inspection.property.location.street1", 'size="30", maxlength="100"' /></td>
				<th>CITY*</th>
				<td><@spring.formInput "criteria.inspection.property.location.city", 'size="30", maxlength="100"' /></td>
			</tr>
			<tr>
				<th>STATE*</th>
				<td class="middle">
					<@spring.bind "criteria.inspection.property.location.state" />
					<select id="${spring.status.expression}" name="${spring.status.expression}">
						<option value=""<@spring.checkSelected ""/>>-- SELECT STATE --</option>
						<#list states as option>
							<option value="${option}"<@spring.checkSelected option/>>${option.longName}</option>
						</#list>
					</select>		
				</td>
				<th>ZIP*</th>
				<td><@spring.formInput "criteria.inspection.property.location.zipCode", 'size="10", maxlength="5"' /></td>
			</tr>
			<tr>
				<th>CROSS STREET</th>
				<td class="middle"><@spring.formInput "criteria.inspection.property.crossStreet", 'size="30", maxlength="100"' /></td>
				<th>SUBDIVISION NAME</th>
				<td><@spring.formInput "criteria.inspection.property.subdivisionName", 'size="30", maxlength="100"' /></td>
			</tr>
			<tr>
				<th>STATUS</th>
				<td class="middle"><@spring.formSingleSelect "criteria.inspection.property.occupied", occ /></td>
				<th></th>
				<td></td>
			</tr>
			<tr>
				<th>LOCKBOX TYPE</th>
				<td class="middle"><@imacro.enumDropDown "criteria.inspection.lockboxType", lockboxTypes /></td>
				<th>LOCKBOX REALTOR CODE (if you have a lockbox)</th>
				<td><@spring.formInput "criteria.inspection.lockboxRealtorCode", 'size="30", maxlength="20"'/></td>
			<tr>
				<th>DWELLING TYPE</th>
				<td class="middle"><@imacro.enumDropDown "criteria.inspection.property.propertyType", propertyTypes /></td>
				<th>WHO WILL BE PRESENT DURING INSPECTION?</th>
				<td><@imacro.enumDropDown "criteria.inspection.presentAtInspection", presentAtInspectionOptions /></td>	
			</tr>
			<tr>
				<th>WILL THE ELECTICITY BE ON?</th>
				<td class="middle"><@spring.formSingleSelect "criteria.inspection.electricityExpectedToBeOn", yesno /></td>	
				<th>WILL THE GAS BE ON?</th>
				<td><@spring.formSingleSelect "criteria.inspection.gasExpectedToBeOn", yesno /></td>	
			</tr>
			<tr>
				<th>WILL THE WATER BE ON?</th>
				<td class="middle"><@spring.formSingleSelect "criteria.inspection.waterExpectedToBeOn", yesno /></td>	
				<th>TYPE OF FOUNDATION</th>
				<td class="middle"><@imacro.enumDropDown "criteria.inspection.property.foundationType", foundationTypes /></td>
			</tr>
			
			<tr>
				<th>NUMBER OF STORIES</th>
				<td class="middle"><@spring.formSingleSelect "criteria.inspection.property.numberOfStories", stories /></td>
				<th>OTHER STRUCTURES (detached garage, etc)</th>
				<td class="middle"><@spring.formInput "criteria.inspection.property.otherStructures", 'size="30", maxlength="255"' /></td>
			</tr>
			<tr>
				<th>YEAR OF CONSTRUCTION</th>
				<td class="middle">
					<@spring.bind "criteria.inspection.property.constructionYear" />
					<#if criteria.inspection.property.constructionYear == 0>							
						<input type="text" maxlength="4" name="${spring.status.expression}" 
							value="" />
					<#else>
						<input type="text" name="${spring.status.expression}" 
							value="${spring.status.value?default("")}" />							
					</#if>
				</td>
				<th></th>
				<td></td>
			</tr>
			</table>
		</div>
	</div>
	
	<div class="databoxWrapper">
		<div class="databox">
			<h1>PROPERTY LISTING INFORMATION</h1>
			<table class="databoxLabelTable4Cols">
			<tr>
				<th>PRICE</th>
				<td class="middle">
					<@spring.bind "criteria.inspection.property.listedPrice" />
					<#if criteria.inspection.property.listedPrice == 0>							
						<input type="text" maxlength="13" name="${spring.status.expression}" 
							value="" />
					<#else>
						<input type="text" maxlength="13" name="${spring.status.expression}" 
							value="${spring.status.value?default("")}" />							
					</#if>
				</td>
				<th>NUMBER OF AC UNITS</th>
				<td><@spring.formSingleSelect "criteria.inspection.property.numberOfAcUnits", acunits /></td>
			</tr>
			<tr>
				<th>NUMBER OF BEDROOMS</th>
				<td class="middle"><@spring.formSingleSelect "criteria.inspection.property.numberOfBedrooms", beds /></td>
				<th>NUMBER OF BATHROOMS</th>
				<td><@spring.formSingleSelect "criteria.inspection.property.numberOfBathrooms", baths /></td>
			</tr>
			<tr>
				<th>SIZE IN SQUARE FEET</th>
				<td class="middle">
					<@spring.bind "criteria.inspection.property.squareFeet" />
					<#if criteria.inspection.property.squareFeet == 0>							
						<input type="text" name="${spring.status.expression}" 
							value="" size="10" maxlength="13"/>
					<#else>
						<input type="text" name="${spring.status.expression}" 
							value="${spring.status.value?default("")}"  size="10" maxlength="13"/>							
					</#if>
				</td>
				<th></th>
				<td></td>
			</tr>
			</table>
		</div>
	</div>
	
	<div class="databoxWrapper">
		<div class="databox">
			<h1>LISTING AGENT INFORMATION</h1>
			<table class="databoxLabelTable4Cols">
			<tr>
				<th>AGENT NAME</th>
				<td class="middle"><@spring.formInput "criteria.inspection.listingAgentName", 'size="30", maxlength="100"' /></td>
				<th>AGENT PHONE NUMBER</th>
				<td><@spring.formInput "criteria.inspection.listingAgentPhoneNumber", 'size="30", maxlength="20"' /></td>
			</tr>
			</table>
		</div>
	</div>
	
	
	<div class="databoxWrapper">
		<div class="databox">
			<h1>ADDITIONAL SERVICES</h1>
			<#if inspectorCompany.optionalServices?? && (inspectorCompany.optionalServices?size > 0)>
				<table class="databoxLabelTable">
				<@spring.bind "criteria.inspection.optionalServices" />
				<#list inspectorCompany.optionalServices as availableService>
					<tr>
						<td>
						<!-- TODO: Show description too -->
						<input type="checkbox" 
							<#if criteria.inspection.optionalServiceIds?seq_contains(availableService.id)>
								checked="checked" 
							</#if>
						name="optionalService.id.${availableService_index}" class="checkbox">  
						</td>
						<td  style="width: 100%"><b>${availableService.title?upper_case} ($${availableService.price}):</b> ${availableService.description!}<br/></td>
					</tr>
				</#list>
				</table>	
				
			<#else>
				<p class="databoxFreeForm">
					You currently do not offer any additional services.
				</p>
			</#if>
		</div>
	</div>
	
	<div class="databoxWrapper">
		<div class="databox">
		<h1>REFERRING REAL ESTATE AGENT INFORMATION</h1>
		
			<#if (criteria.inspection.referringAgent.id)??>
				<table class="databoxLabelTable2Cols">
					<tr>
						<th>AGENT:</th>
						<td>${criteria.inspection.referringAgent.name!} - ${criteria.inspection.referringAgent.company!}</td>
					</tr>
				</table>
			</#if>
					
			<p class="databoxFreeForm">
					
				<script language="javascript">
					//Written in javascript so it won't show up on non-javascript enabled clients (like a Blackberry)
					<#if (criteria.inspection.referringAgent.id)??>
						document.write('To change the referring agent, just begin typing the new agent\'s name in the field below:<br />');
					<#else>
						document.write('To add a referring agent, just begin typing the agent\'s name in the field below: <br />');
					</#if>
						
					document.write('<input id="referringAgentSelection" name="selectedRealtor" autocomplete="off" type="text" value="${criteria.selectedRealtor!}" style="width: 220px; margin-top: 10px; margin-left: 10px"/>');
					document.write('<div class="autocomplete" id="realtorsDropDown" style="display:none"></div>');
						
					new Autocompleter.Local('referringAgentSelection', 'realtorsDropDown', realtorsList, {frequency:0.1});
				</script>
					
				<noscript>
					To add/edit your referring realtor, please choose the agent from the list below.<br /> 
					<!-- for Blackberrys, etc -->
					<select id="referringAgentId" name="referringAgentId" style="margin-top: 10px">
						<option value="">-- Select Agent --</option>
							<#list referringRealtors as realtor>
								<option value="${realtor.id}">${realtor.name.first} ${realtor.name.last} - ${realtor.company}</option>
							</#list>
						</select>	
					</noscript>
			</p>
				
			<p class="databoxFreeForm">
				<i><input type="checkbox" name="addRealtorInfo" 
					value="true" <#if criteria.addRealtorInfo??>checked</#if> 
					class="checkbox" onclick="toggleAgentFields(this);">
					
				   Or add a new real estate agent</i>  
			</p>
				
			<div id="enterAgentFields">
				<h2>NEW AGENT INFO</h2>
				<table class="databoxLabelTable4Cols">
					<tr>
						<th>FIRST NAME*</th>
						<td class="middle"><@spring.formInput "criteria.referringRealEstateAgent.name.first", 'size="30"' /></td>
						<th>LAST NAME*</th>
						<td><@spring.formInput "criteria.referringRealEstateAgent.name.last", 'size="30"' /></td>
					</tr>
					<tr>
						<th>COMPANY*</th>
						<td class="middle"><@spring.formInput "criteria.referringRealEstateAgent.company", 'size="30"' /></td>
						<th>OFFICE</th>
						<td><@spring.formInput "criteria.referringRealEstateAgent.office", 'size="30"' /></td>
					</tr>
					<tr>
						<th>PHONE</th>
						<td><@spring.formInput "criteria.referringRealEstateAgent.cellPhone", 'size="30"' /></td>
						<th>EMAIL</th>
						<td class="middle"><@spring.formInput "criteria.referringRealEstateAgent.email", 'size="30"' /></td>
					</tr>
				</table>
			</div>
			
			<script>
				toggleAgentFields(document.forms[0].addRealtorInfo);
			</script>
		</div>
	</div>	
		
	<div class="databoxWrapper">
		<div class="databox">
			<h1>SPECIAL INSTRUCTIONS</h1>
			<table class="databoxLabelTable2Cols">
			<tr>
				<th>COMMENTS</th>
				<td><@spring.formTextarea "criteria.inspection.comments", 'rows="5" cols="30"'/></td>
			</tr>
			</table>
		</div>
	</div>
	
		<div class="databoxWrapper">
		<div class="databox">
			<h1>CONTACT</h1>
			
			<p class="databoxFreeForm">
				<input type="checkbox" name="sendEmailToBuyer" 
					value="true" <#if criteria.sendEmailToBuyer>checked</#if> 
					class="checkbox"> 
					<#if criteria.inspection.id??>
						Send a new confirmation email to the customer?
					<#else>
						Send confirmation email to customer?
					</#if>
			</p>
			
			<p class="databoxFreeForm">
				<input type="checkbox" name="sendEmailToInspector" 
					value="true" <#if criteria.sendEmailToInspector>checked</#if> 
					class="checkbox"> 

				<#if criteria.inspection.id??>
						Send a new confirmation email to the inspector?
				<#else>
						Send confirmation email to inspector?
				</#if>
			</p>
			
			<p class="databoxFreeForm">
				<input type="checkbox" name="sendEmailToRealtor" 
					value="true" <#if criteria.sendEmailToRealtor>checked</#if> 
					class="checkbox"> 

				<#if criteria.inspection.id??>
						Send a new thank you email to the referring realtor (if there is one)?
				<#else>
						Send thank you email to referring realtor (if there is one)?
				</#if>
			</p>
		</div>
	</div>
	
	<br class="clearAll" />
	<input type="submit" value="SAVE" class="formButton"/>
	<a href="inspections.html" class="formLink">-CANCEL-</a>
		
	</form>
</div>
	
</body>
</html>
